import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { ItemConfig } from "../../resource/ItemConfig";
import { ColorConfig } from "../../resource/ColorConfig";
type int = number;
//class QuestionRewardWindow
    
    export  class QuestionRewardWindow extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(300, 160);
            title = Language.getString(35614);
            titleHeight = 30;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=ObjCreate.createBg(17, 42, 265, 105, this);
            this._txt = ObjCreate.createTextField("", 20, 55, 260, 90, this);
            this._txt.multiline = true;
            this._txt.wordWrap = true;
            return;
        }

        public updateExpData(arg1: int, arg2: Array<any>): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=0;
            var loc1=Language.getStringByParam(35615, this.formatNum(arg1));
            var loc6=0;
            while (loc6 < arg2.length) 
            {
                loc4 = arg2[loc6].code;
                loc5 = arg2[loc6].itemNum;
                if (loc4 != 0) 
                {
                    if ((loc2 = ItemConfig.instance.getInfoByCode(loc4)) != null) 
                    {
                        loc3 = ColorConfig.instance.getItemColor(loc2.item.color).color;
                        loc1 = loc1 + ",\n" + loc5 + Language.getString(35616) + "<font color=\'" + loc3 + "\'>" + loc2.item.name + "</font>";
                    }
                }
                ++loc6;
            }
            loc1 = loc1 + "</font></p>";
            this._txt.htmlText = loc1;
            return;
        }

        /* internal  */formatNum(arg1: int): string
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=0;
            var loc5=null;
            var loc6=0;
            var loc7=0;
            var loc8=0;
            var loc9=0;
            if (arg1 < 1000) 
            {
                return arg1.toString();
            }
            loc1 = [];
            loc2 = arg1.toString();
            loc3 = loc2.length / 3;
            if ((loc4 = loc2.length % 3) > 0) 
            {
                loc1[0] = loc2.substring(0, loc4);
                loc8 = 1;
                while (loc8 <= loc3) 
                {
                    loc1[loc8] = loc2.substr(loc4, 3);
                    loc4 = loc4 + 3;
                    ++loc8;
                }
            }
            else 
            {
                loc9 = 0;
                while (loc9 < loc3) 
                {
                    loc1[loc9] = loc2.substr(loc4, 3);
                    loc4 = loc4 + 3;
                    ++loc9;
                }
            }
            loc5 = loc1[0] + ",";
            loc6 = 1;
            while (loc6 < loc1.length) 
            {
                loc5 = loc5 + loc1[loc6] + ",";
                ++loc6;
            }
            loc7 = loc5.length;
            return loc5 = loc5.substr(0, (loc7 - 1));
        }

        /* internal */ /* var */_txt: Object /* flash.text.TextField */;
    }
